const app = getApp();
import services from '../../services/clockin';
import common from '../../utils/common';

Page({
  data: {
    isReady: false,
    showList: [],
    approveOptions: {
      0: {
        text: "审批中",
        type: 'gray'
      },
      1: {
        text: "审批通过",
        type: 'resolve'
      },
      2: {
        text: "审批驳回",
        type: 'reject'
      },
    },
    unionid: '',
    isLoading: false,
    pageParams: {
      page: 1,
      size: 10000,
      order_by: 'clock_datetime'
    },
  },
  async onLoad() {
    const {
      unionid
    } = app.globalData.userInfo || {};
    this.setData({
      unionid: unionid || ''
    })
    await this.queryGetApproveOuting();
    this.setData({
      isReady: true
    })
  },
  async queryGetApproveOuting() {
    try {
      const res = await services.getApproveReocrd(this.data.pageParams, this.data.unionid);
      if (res && res.data) {
        this.setData({
          showList: res.data.record_list || []
        })
      }
      console.log('showList', this.data.showList, res.data);
    } catch (error) {
      console.log("获取审批列表失败", error);
    }
  },
});